/*
  学习目标：登录成功后的逻辑处理
  0: 把操作token的常用方法封装起来
    
  步骤：
     1. 存token
     2. 提示用户
     3. 跳转路由
*/

import { loginAPI, sendCodeAPI } from '@/api/login';
import { saveAuth } from '@/utils/storage';
import { Toast } from 'antd-mobile';

export const sendCodeAction = (mobile: string) => {
  return async () => {
    await sendCodeAPI(mobile);
  };
};

export const loginAction = (mobile: string, code: string) => {
  return async () => {
    const res = await loginAPI(mobile, code);
    saveAuth(res.data);
    Toast.show('登录成功');
  };
};
